# -*- coding: utf-8 -*-
import sys
import socket
_py = "Core/CC.py"

def get_host_ip():
    ip = None
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8', 80))
        ip = s.getsockname()[0]
    finally:
        s.close()

    return ip

def is_windows():
    os_str = sys.platform
    if os_str == "win32":
        return True
    elif os_str == "linux":
        return False

def get_dir():
    os_str = sys.platform
    if os_str == "win32":
        return '\\'
    elif os_str == "linux":
        return '/'
    return None


def get_app_path():
    md = get_dir()
    soft_dir_link = sys.argv[0]
    soft_dir_links = soft_dir_link.split(md)
    soft_dir_links.pop()
    return md.join(soft_dir_links)

def is_frozen():
    """判断程序是否运行在 PyInstaller 打包后的环境中"""
    return getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
